// Copyright (C) 1998-2008, Sumisho Computer Systems Corp. All Rights Reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @author Hitoshi Okada
 */

package com.curlap.orb.type;

/**
 * SerializableRecordField
 */
public class SerializableRecordField implements java.io.Serializable 
{
	private static final long serialVersionUID = 1L;

    private String name;
    private String caption;
    private Class domain;
    private boolean isModifiable = true;
    private boolean isNullable = false;
    private Object defaultValue = null;
    private int indexType = 2; // 0:unique, 1:multiple, 2:none
    
    // constructors
    public SerializableRecordField(String name, Class domain)
    {
        this.name = name;
        this.caption = name;
        this.domain = domain;
    }
 
    public SerializableRecordField(String name, String caption, Class domain)
    {
        this.name = name;
        this.caption = (caption != null ? caption : name);
        this.domain = domain;
    }
    
    public SerializableRecordField(String name, String caption, Class domain, 
            boolean isModifiable, boolean isNullable, Object defaultValue, int indexType)
    {
        this.name = name;
        this.caption = (caption != null ? caption : name);
        this.domain = domain;
        this.isModifiable = isModifiable;
        this.isNullable = isNullable;
        this.defaultValue = (isNullable ? null : defaultValue);
        this.indexType = indexType;
    }
    
    // setters/getters
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }

    public String getCaption()
    {
        return caption;
    }
    public void setCaption(String caption)
    {
        this.caption = caption;
    }

    public Class getDomain()
    {
        return domain;
    }
    public void setDomain(Class domain)
    {
        this.domain = domain;
    }
    
    public boolean getIsModifiable()
    {
        return isModifiable;
    }
    public void setIsModifiable(boolean isModifiable)
    {
        this.isModifiable = isModifiable;
    }

    public boolean getIsNullable()
    {
        return isNullable;
    }
    public void setIsNullable(boolean isNullable)
    {
        this.isNullable = isNullable;
    }
    
    public Object getDefaultValue()
    {
        return defaultValue;
    }
    public void setDefaultValue(Object defaultValue)
    {
        this.defaultValue = defaultValue;
    }
    
    public int getIndexType()
    {
        return indexType;
    }
    public void setIndexType(int indexType)
    {
        this.indexType = indexType;
    }
}
